package br.rui.incorporacao.persistencia;

import java.sql.Connection;
import java.sql.SQLException;

import br.rui.planilhas.util.Banco;



public abstract class Persistencia {
	
	private Connection conn;
	
	public Persistencia(Connection conn) {
		this.conn = conn;
	}
	
	public Persistencia() {
		this.conn = Banco.getInstance().getConexao();
	}

	public abstract void save(Object o) throws SQLException;

	public abstract void delete(Object o) throws SQLException;
	
	public abstract void update(Object o) throws SQLException;
	
	public abstract Object find(Object o) throws SQLException;
	
	public void setConn(Connection conn){		
		this.conn = conn;		
	}
	
	public Connection getConn(){
		return this.conn;
	}
	
	public void close() {
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Bloco catch gerado automaticamente
			e.printStackTrace();
		}
		
	}
	
	public void close(Connection conn) {
		try {
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
